﻿Public Class PrintLogUpdate
#Region "加载数据"
    Private _Id As String = ""
    Public Overrides Sub LoadData()

        'A-2009-10-11
        Me.MyDataView1.BrowserData = True
        'A-2009-10-11

        Dim strSql_1 As String
        Dim strSql1_1 As String
        strSql_1 = "select ID,DateTime as TITLE  from PrintLog                 Where 1=1 "
        If Me.cbo类型.Text.Trim <> "" Then
            strSql_1 &= " And type=" & (Me.cbo类型.SelectedIndex - 1)
        End If
        strSql_1 &= " ORDER BY DateTime DESC"
        strSql1_1 = "select count(*) as PageCount from PrintLog  Where 1=1  "
        If Me.cbo类型.Text.Trim <> "" Then
            strSql1_1 &= " And type=" & (Me.cbo类型.SelectedIndex - 1)
        End If
        Me.MyDataView1.SetRsSQLITE(strSql_1, strSql1_1, ct, 1)
    End Sub

    Private Sub cbo类型_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo类型.SelectedIndexChanged
        LoadData()
    End Sub

#Region "窗体数据保存的重载方法 A-2010-09-06"
    Public Overrides Sub 保存窗体数据到数据库(ByRef dtData As System.Data.DataTable)
        dtData.Rows.Add(New Object() {"类型", "", Me.cbo类型.SelectedIndex.ToString})
    End Sub

    Public Overrides Sub 存取数据库数据到窗体(ByVal dtDbData As System.Data.DataTable)
        Dim index As Integer = 查找数据("类型", "", "1", dtDbData)
        If index > 0 Then
            Me.cbo类型.SelectedIndex = index
        End If
    End Sub
#End Region

#Region "更新明细"
    Public Overrides Function DoSelect(ByVal strId As String) As Boolean
        MyBase.DoSelect(strId)
        _Id = strId
        Return True
    End Function
#End Region
#Region "重载删除事件"
    Public Overrides Function DoDelete() As Boolean
        Dim rs As ADODB.Recordset = ct.GetTable("select * from PrintLog  where ID='" + _Id + "'")

        Dim CMD As New ADODB.Command
        CMD.CommandText = "DELETE from PrintLog  where ID='" + _Id + "'"
        If ct.ExcCommand(CMD) Then
            '添加删除记录功能  A-2010-03-24
            ct.AddDeleteDetal("PrintLog", New String() {"ID", "", ""}, New String() {_Id, "", "", ""}, Me.strName)
            '添加删除记录功能  A-2010-03-24 
            ShowMessageBox("删除成功")
        Else
            ShowMessageBox("删除失败")
        End If
        LoadData()
        Return True
    End Function
#End Region

#Region "删除CHECK"
    Public Overrides Function DoDeleteCheck() As Boolean
        DoDeleteCheck = False
        If ShowMessageResult("是否删除本条记录") = Windows.Forms.DialogResult.No Then Exit Function
        If _Id = "" Then
            ShowMessageBox("没有选中任何备注")
            Exit Function
        End If
        DoDeleteCheck = True
    End Function
#End Region
#End Region
End Class
